/*
Borealis Library
A library of commonly used hydrological modeling building blocks

Copyright (C) 2008  Chris Marsh

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef CLOCK_H
#define CLOCK_H

#ifdef _WIN32   
	#include <windows.h>
#else          
	#include <sys/time.h>
#endif

#include <stack>

namespace Borealis
{

	class Clock
	{
		public:
			/*
			Function: Clock
				Creates a clock.

			Parameters: 
			None

			Throws:
			Never

			Returns:   
		
			*/
			Clock();

			/*
			Function: Tic
				Begins a timer

			Parameters: 
				None

			Throws:
				Never

			Returns:   
				
			*/
			void tic();

			/*
			Function: Toc
				Returns the time elapsed in micro-seconds since the last Tic() call

			Parameters: 
				None

			Throws:
				Never

			Returns:   
				double - Time elapsed, micro-seconds. -1.0 if Tic() hasn't been called yet.
			*/
			double toc();
			
		private:
			

			#ifdef _WIN32
				LARGE_INTEGER m_frequency;    
				std::stack<LARGE_INTEGER> m_timers;
			#else
				std::stack<timeval> m_timers;
			#endif
	};
}

#endif